{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
	<form class="layui-form gg-form-bar border-t border-x" lay-filter="barsearchform">
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" class="layui-input" id="diff_time" placeholder="维修日期" readonly name="diff_time">
		</div>
		<div class="layui-input-inline" style="width:300px">
			<input type="text" name="keywords" placeholder="输入关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline" style="width:150px">
			<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>
			<button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>
		</div>
	</form>
	<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
  	<button class="layui-btn layui-btn-sm tool-add" type="button" data-href="/adm/property/repair_add">+ 添加维修记录</button>
  </div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
	<script>
	const moduleInit = ['tool','tablePlus','laydatePlus'];
	function gouguInit() {
		var table = layui.tablePlus, tool = layui.tool,form = layui.form,laydatePlus = layui.laydatePlus;	
		var diff_time = new laydatePlus({'target':'diff_time'});		
		
		layui.pageTable = table.render({
			elem: '#test'
			,toolbar: '#toolbarDemo'
			,title:'维修记录列表'
			,url: "/adm/property/repair_list"
			,is_excel: true
			,page: true
			,cellMinWidth: 60
			,height: 'full-114'
			,cols: [[
				{field:'id',width:80, title: 'ID号', align:'center'}
				,{field:'repair_time',title: '维修日期',align: 'center',width: 100}
				,{field:'cost',width:100, title: '维修费用(元)', align:'center',style:"color:#16b777"}
				,{field:'title',minWidth:240,title: '资产名称'}
				,{field:'cate',width:120, title: '资产分类', align:'center'}
				,{field:'brand',title: '资产品牌',align: 'center',width: 100}
				,{field:'model',title: '资产型号',align: 'center',width: 100}
				,{field:'director_name',title: '跟进人',align: 'center',width: 80}
				,{field:'create_time',title: '记录时间',align: 'center',width: 130}
				,{width:120,fixed:'right', title: '操作', align:'center',templet: function(d){
					var html='<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">详情</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>';
					return html;
				}}
			]]
		});
		
		table.on('tool(test)',function (obj) {
			var that = this;
			if(obj.event === 'edit'){					
				tool.side("/adm/property/repair_add?id="+obj.data.id);
			}
			if(obj.event === 'view'){					
				tool.side("/adm/property/repair_view?id="+obj.data.id);
			}
			if(obj.event === 'del'){
				layer.confirm('确定要删除该维修记录吗?', {icon: 3, title:'提示'}, function(index){
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							layui.pageTable.reload();
						}
					}
					tool.post("/adm/property/repair_del", {id: obj.data.id}, callback);
					layer.close(index);
				});
				return;
			}
		});
		
		//监听搜索提交
		form.on('submit(webform)', function(data){
			layui.pageTable.reload({where:data.field,page:{curr:1}});
			return false;
		});
	}
	</script>
{/block}
<!-- /脚本 -->